package com.free.ppcar.common;

public class JSObject {

    public static String JS_GETCOUPORN;
    public static String JS_PAY;

    static{
        JS_GETCOUPORN = "(function(){$.ajax({\n" +
                "        type: \"post\",\n" +
                "        url: \"/ashx/shop.ashx\",\n" +
                "        data: \"action=savegoods&goodsid=1471&number=1\",\n" +
                "        dataType: \"json\",\n" +
                "        timeout: 60000,\n" +
                "        success: function (data) {\n" +
                "            console.log(data);\n" +
                "            if (data.result == 1) {\n" +
                "                window.android.callAndroid(\"停车券兑换成功 \");;\n" +
                "            }else {\n" +
                "\t\t\t    window.android.callAndroid(\"停车券兑换失败 \" + data.msg);;\n" +
                "\t\t\t}\n" +
                "        }\n" +
                "    });})()";
        JS_PAY = "(function(){\n" +
                "    // 判断是否缴费\n" +
                "    var setfree = parseInt($(\"#totalMoney\").html());\n" +
                "    var zz = setfree;\n" +
                "    if(setfree == 0){\n" +
                "        console.log('您已缴费！');\n" +
                "        return;\n" +
                "    }\n" +
                "\n" +
                "    window.maxIntegral=80000;\n" +
                "\n" +
                "    //选中优惠券\n" +
                "    $('input[name=\"cardRadio\"]').prop('checked',true);\n" +
                "    $(\"#couponPrice\").html(9);\n" +
                "\n" +
                "    setfree = parseInt($(\"#totalMoney\").html());\n" +
                "    //使用积分\n" +
                "    while(setfree > 0){\n" +
                "        usePoint(1);\n" +
                "        setfree = parseInt($(\"#totalMoney\").html());\n" +
                "        console.log(setfree);\n" +
                "    }\n" +
                "    //设置积分为0\n" +
                "    $(\"#sendPoint\").val(0);\n" +
                "    console.log('设置完成');\n" +
                "    console.log('请点击”使用积分/卡券”按钮');\n" +
                "\n" +
                "\n" +
                "    // 获取车牌号和优惠券码，进行支付\n" +
                "    var car_no = window.location.href.substr(window.location.href.lastIndexOf('=')+1,window.location.href.length);\n" +
                "    var ticketno = $(\":checkbox[name='cardRadio']\")[0].getAttribute('data-code');\n" +
                "    $.ajax({\n" +
                "        type: 'POST',\n" +
                "        url: \"http://vip.lcmsh.com/car_park_normal/pay?mt=cashPay&parkID=88&integral=0&fee=\"+zz+\"&car_no=\" + car_no + \"&payNo=&ticketno=\"+ticketno,\n" +
                "        data: \"\",\n" +
                "        dataType: \"json\",\n" +
                "        success: function (data) {\n" +
                "            console.log(data);\n" +
                "            var status = data.status;\n" +
                "                if (status == 1) {\n" +
                "                    location.href = \"pay_success?payable=\"+zz+\"&reduce=63&couponreduce=9\";\n" +
                "                }else{\n" +
                "                    console.log('缴费失败');\n" +
                "                }\n" +
                "            }\n" +
                "    });\n" +
                "})()";
    }
}
